{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 首先引入QUANTAXIS\n",
    "\n",
    "import QUANTAXIS as QA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "QAFetch 是对于数据获取的封装\n",
    "\n",
    "QAFetch有两个主要的函数类别:\n",
    "\n",
    "QA_fetch_ 类函数  此类函数是从数据获取数据\n",
    "\n",
    "QA_fetch_get 类函数 此类函数是从网络上获取数据\n",
    "\n",
    "\"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# QAFetch\n",
    "\n",
    "# 获取股票日线:\n",
    "QA.QA_fetch_get_stock_day('tdx','000001','2017-01-01','2017-11-01')\n",
    "QA.QA_fetch_get_stock_day('tdx','000001','2017-01-01','2017-01-31',level='w')# 周线数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取股票分钟线 \n",
    "# 参数:\n",
    "# 引擎:tdx\n",
    "# 股票代码:000001\n",
    "# 开始日期\n",
    "# 结束日期\n",
    "# 类别: 1min,5min,15min,30min,60min\n",
    "QA.QA_fetch_get_stock_min('tdx','000001','2017-11-01','2017-12-01',level='1min')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 获取股票实时上下五档报价\n",
    "# 这里的第二个参数  可以是一个股票  也可以是一个股票list\n",
    "\n",
    "QA.QA_fetch_get_stock_realtime('tdx','000001')\n",
    "QA.QA_fetch_get_stock_realtime('tdx',['000001','000002'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取股票的列表\n",
    "QA.QA_fetch_get_stock_list('tdx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 获取股票当日分时成交tick\n",
    "QA.QA_fetch_get_stock_transaction_realtime('tdx','000001')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 获取股票历史分笔成交tick\n",
    "QA.QA_fetch_get_stock_transaction('tdx','000001','2017-07-12','2017-07-15')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 获取通达信的股票板块\n",
    "QA.QA_fetch_get_stock_block('tdx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取股票的最新一期的财务报表数据\n",
    "\n",
    "QA.QA_fetch_get_stock_info('000001')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取股票除权除息数据\n",
    "QA.QA_fetch_get_stock_xdxr('tdx','000001')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取指数,基金日线数据\n",
    "# 用法和stock_day一致  510050是50etf\n",
    "QA.QA_fetch_get_index_day('tdx','510050','2017-01-01','2017-01-31')\n",
    "QA.QA_fetch_get_index_day('tdx','510050','2017-01-01','2017-01-31',level='w')# 周线数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取指数,基金分钟线数据\n",
    "# 用法和stock_min一致  510050是50etf\n",
    "QA.QA_fetch_get_index_min('tdx','510050','2017-11-01 09:30:00','2017-11-30 15:00:00','15min')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取期货日线/周线/月线/季度线/年线\n",
    "# 期货指数 RBL8 螺纹主连 RBL9 螺纹指数\n",
    "QA.QA_fetch_get_future_day('tdx','RB1801','2017-11-01','2017-11-30',level='week')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取期货分钟线\n",
    "# 期货指数 RBL8 螺纹主连 RBL9 螺纹指数\n",
    "QA.QA_fetch_get_future_min('tdx','RB1801','2017-11-01','2017-11-30',level='1min')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
